﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using ERPStudio;

namespace Administrare
{
    public partial class FoxProFrm : FrmRezumat
    {
        public FoxProFrm()
            : base(null)
        {
            InitializeComponent();
        }

        private void FoxProFrm_Load(object sender, EventArgs e)
        {
            AddButton("Deschide", global::ERPStudio.Properties.Resources.table_green_48, DeschideFisier, ToolStripItemAlignment.Right,true);
        }
        private void DeschideFisier(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                String ConnectionString,path1=openFileDialog1.FileName.Replace(openFileDialog1.SafeFileName,"");
                String fName = openFileDialog1.SafeFileName.Replace(".DBF", "");
                ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source = "+path1+";Extended Properties =dBase IV;";
                System.Data.OleDb.OleDbConnection dBaseConnection;
                dBaseConnection = new System.Data.OleDb.OleDbConnection(ConnectionString);
                dBaseConnection.Open();
                //System.Data.OleDb.OleDbCommand dBaseCommand;
                //dBaseCommand = new System.Data.OleDb.OleDbCommand("CREATE TABLE abc(version CHAR(50),tip int) ", dBaseConnection);
                //System.Data.OleDb.OleDbDataReader dBaseDataReader;
                //dBaseCommand.ExecuteNonQuery();

                OleDbDataAdapter dA = new OleDbDataAdapter("SELECT * FROM " + fName, dBaseConnection);
                dA.Fill(dataSet1, fName);
                BindingSource bs = new BindingSource(dataSet1, fName);
                dataGV.DataSource = bs;
                //dataGV.DataMember = fName;
                
                
               // textBox2.Text = dBaseDataReader.GetValue(0).ToString();

            }
        }

        
    }
}
